/*
 * @(#)ReplaceAllInfo.java $version 2010. 8. 11
 *
 * Copyright 2007-2010 NHN Corp. All rights Reserved. 
 * NHN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package com.nhncorp.usf.core.config;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Web Platform Development Team
 */
public class ReplaceAllInfo {

    /**
     * OperationAttributes 객체 참조자.
     */
    private static ReplaceAllInfo replaceAllInfo;

    /**
     * {@link java.util.Map} to manage Operation Replacements.
     */
    private Map<String, String> replaceInfo = new HashMap<String, String>();

    /**
     * operationAttributeInfo 객체 반환.
     *
     * @return ReplaceAllInfo the single instance of ReplaceAllInfo.
     */
    public static ReplaceAllInfo getInstance() {
        if (replaceAllInfo == null) {
            replaceAllInfo = new ReplaceAllInfo();
        }

        return replaceAllInfo;
    }

    /**
     * put replacement to {@link java.util.Map}.
     *
     * @param oldValue the original string value
     * @param newValue the replace string value
     */
    public void putReplaceInfo(String oldValue, String newValue) {
        replaceInfo.put(oldValue, newValue);
    }

    /**
     * get replacement from {@link java.util.Map}.
     *
     * @param name the original string value
     * @return newValue the replace string value
     */
    public String getReplaceInfo(String name) {
        return replaceInfo.get(name);
    }

    /**
     * Returns <tt>true</tt> if this map contains a mapping for the specified
     * oldValue of name.
     *
     * @param oldValue the orignal string value
     * @return boolean the orignal string exist or don't exist
     */
    public boolean containsKey(String oldValue) {
        return replaceInfo.containsKey(oldValue);
    }

    /**
     * clean all object
     */
    public void clear() {
        replaceInfo.clear();
    }
}
